package io.hepu.robotize.exception;

import io.hepu.robotize.enums.IStatus;
import org.apache.shiro.authc.AuthenticationException;

public class AuthGrantException extends AuthenticationException {
    private int code;
    private String message;

    public AuthGrantException(int code, String message) {
        this.setCode(code);
        this.setMessage(message);
    }

    public static AuthGrantException of(IStatus status) {
        return new AuthGrantException(status.code(), status.message());
    }

    public static final AuthGrantException AUTHENTICATED_INVALID = of(IStatus.AUTHENTICATED_INVALID);
    public static final AuthGrantException UNAUTHORIZED = of(IStatus.UNAUTHORIZED);

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
